<template>
  <div>
    <el-input type="text" v-model="loginForm.username" placeholder="账号"></el-input>
    <el-input type="password" v-model="loginForm.password" placeholder="密码"></el-input>
    <el-button type="primary" @click="submitLogin">登录</el-button>
  </div>
</template>

<script>
import {LoginService} from './login/loginService';

export default {
  name: "Index",
  data() {
    return {
      loginForm: {
        username: 'admin',
        password: 123
      }
    }
  },
  methods: {
    submitLogin() {
      console.log("goLogin");
      // this.$store.dispatch('goLogin', this.message).then((res) => {
      //   console.log(res);
      // })

      this.postRequest('/user/doLogin', this.loginForm).then(resp => {
        console.log("resp.data: ", resp.data);
        if (resp && resp.status === 200) {
          var data = resp.data;
          console.log("data", data);
          this.$store.commit('login', data.obj);
          var path = this.$route.query.redirect;
          this.$router.replace({path: path == '/' || path == undefined ? '/index' : path});
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
